package com.xiaolin.designmode.singleton;

/**
 * @ClassName InnerSingleton
 * @Description 静态内部类
 * @Detail 静态内部类的方式效果类似双检锁，但实现更简单。但这种方式只适用于静态域的情况，双检锁方式可在实例域需要延迟初始化时使用。线程安全
 * @Author MyPC
 * @Date 2020/7/18
 * @Version 1.0
 */
public class InnerSingleton {
    //编写静态内部类,在静态内部类初始化InnerSingleton对象
    private static class SingletonHolder{
        private static InnerSingleton INSTANCE=new InnerSingleton();
    }
    private InnerSingleton(){}
    public static InnerSingleton innerSingleton(){
        return SingletonHolder.INSTANCE;
    }
}
